package collisions;

import com.golden.gamedev.object.Sprite;
import com.golden.gamedev.object.collision.BasicCollisionGroup;

import sprites.TDEntity;
import sprites.Projectile;

/**
 * Deals with the collision between a friendly projectile and an enemy.
 * 
 * @author Alex Lee (hl69)
 */
public class ProjectileEnemyCollision extends BasicCollisionGroup
{

	@Override
	public void collided(Sprite s1, Sprite s2)
	{
		Projectile projectile = (Projectile)s1;
		TDEntity enemy = (TDEntity)s2;
		
		/*
		 * Deal damage to the enemy. If the enemy has no more hitpoints,
		 * consider it dead; remove it and give the player some money.
		 */
		if(enemy.damage(projectile.getDamage()) <= 0)
		{
			enemy.kill();
			enemy.setActive(false);
		}
		
		/*
		 * The projectile disappears.
		 */
		projectile.setActive(false);
	}

}
